{extend name="public:layout" /}
{block name="title"}备份还原{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 备份还原</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <a class="btn btn-primary" href="javascript:;" onclick="handle('backup');">
                    <i class="fa fa-plus"></i>&nbsp;备份数据库
                </a>
            </div>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>备份名称</th>
                    <th>备份时间</th>
                    <th>备份大小</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <th scope="row">{$key}</th>
                    <td>{$vo.name}</td>
                    <td>{$vo.time}</td>
                    <td>{$vo.size}</td>
                    <td>
                        <a class="btn btn-xs btn-success" href="{:url('bak',['action'=>'dowonload','name'=>$vo['name']])}">下载</a>
                        <button type="button" class="btn btn-xs btn-warning" onclick="handle('restore','{$vo.name}')">还原</button>
                        <button type="button"  class="btn btn-xs btn-danger" onclick="handle('del','{$vo.name}')">删除</button>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    function handle(action,name){
        if (action){
            top.layer.msg('正在处理中……', {icon: 16,time:100000, shade: 0.01});
            $.post("{:url('bak')}",{action:action,name:name},function(response){
                top.layer.closeAll();
                if (response){
                    top.layer.msg(response, {icon: 1, time: 800}, function () {
                        rePage();
                    });
                }else{
                    top.layer.alert('操作失败，请重试!', {icon: 2});
                }
            });
        }
    }
</script>
{/block}